define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    function get_need_number(){
        $.post("qingdongwms/customer/need/get_need_number",function (data){
            $('.news_b').html(data.data.news);
            $('.notice_b').html(data.data.notice);
            $('.lead_b').html(data.data.lead);
            $('.customer_b').html(data.data.customer);
            $('.business_b').html(data.data.business);
            $('.contract_b').html(data.data.contract);
            $('.examine_contract').html(data.data.examine);
            $('.examine_receivables').html(data.data.receivables);
            $('.achievement_b').html(data.data.achievement);
            $('.quote_b').html(data.data.quote);
            $('.consume_b').html(data.data.consume);
            $('.approval_b').html(data.data.approval);
            $('.invoice_b').html(data.data.invoice);
            $('.delivery_b').html(data.data.delivery);
            $('.instock_b').html(data.data.instock);
            $('.outstock_b').html(data.data.outstock);
            top.window.Backend.api.sidebar({
                'qingdongwms/customer/need/index':[data.data.number, 'red', 'badge'],
                'qingdongwms/customer/need':[data.data.number, 'red', 'badge'],
                'qingdongwms/examine/examine/index':[data.data.examine, 'red', 'badge'], //合同
                'qingdongwms/examine/examine/consume':[data.data.consume, 'red', 'badge'],
                'qingdongwms/examine/examine/receivables':[data.data.receivables, 'red', 'badge'],
                'qingdongwms/examine/examine/achievement':[data.data.achievement, 'red', 'badge'],
                'qingdongwms/examine/examine/work':[data.data.approval, 'red', 'badge'],
                'qingdongwms/canlendar/canlendar':[data.data.eventOne, 'red', 'badge'],
                'qingdongwms/examine/examine/quote':[data.data.quote, 'red', 'badge'],
                'qingdongwms/examine/examine/invoice':[data.data.invoice, 'red', 'badge'],
                'qingdongwms/examine/examine/delivery':[data.data.delivery, 'red', 'badge'],
                'qingdongwms/examine/examine/instock':[data.data.instock, 'red', 'badge'],
                'qingdongwms/examine/examine/outstock':[data.data.outstock, 'red', 'badge'],
            });
        },'json');
    }
    get_need_number();
    setInterval(function (){
     //   get_need_number();
    },50000);
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init();
            //绑定事件
            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                var panel = $($(this).attr("href"));
                if (panel.length > 0) {
                    Controller.table[panel.attr("id")].call(this);
                    $(this).on('click', function (e) {
                        $($(this).attr("href")).find(".btn-refresh").trigger("click");
                    });
                }
                //移除绑定的事件
                $(this).unbind('shown.bs.tab');
            });
            $('.leads_popover').popover({
                trigger:'hover',
                placement:'right',
                html:'true',
                animation:false,
            });
            //必须默认触发shown.bs.tab事件
            // $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
            this.table.news();
            $(document).on('click','.jstree-anchor',function () {
                var type = $(this).data('id');
                $('.actives').removeClass('actives');
                $(this).addClass('actives');
                $('.tab-table').hide();
                if(type == 1){
                    $('#news').show();

                   $("#one .btn-refresh").trigger("click");
                }else if(type == 2){
                    $('#notice').show();
                    $idinfo = $('#notice').data('id');
                    if($idinfo == 1){
                        $("#two .btn-refresh").trigger("click");
                        return ;
                    }

                    $('#notice').data('id',1);
                }else if(type == 3){ //线索
                    $('#leads').show();
                    $idinfo = $('#leads').data('id');
                    if($idinfo == 1){
                        get_need_number();
                        $("#three .btn-refresh").trigger("click");
                        return ;
                    }


                    $('#leads').data('id',1);
                }else if(type == 4){
                    $('#customer').show();
                    $idinfo = $('#customer').data('id');
                    if($idinfo == 1){
                        $("#four .btn-refresh").trigger("click");
                        return ;
                    }

                    $('#customer').data('id',1);
                }else if(type == 5){
                    $('#business').show();
                    $idinfo = $('#business').data('id');
                    if($idinfo == 1){
                        $("#five .btn-refresh").trigger("click");
                        return ;
                    }


                    $('#business').data('id',1);
                }else if(type == 6){
                    $('#contract_examine').show();
                    $idinfo = $('#contract_examine').data('id');
                    if($idinfo == 1){
                        $("#first .btn-refresh").trigger("click");
                        return ;
                    }
                    $('#contract_examine').data('id',1);
                }else if(type == 7){
                    $('#contract_receivables').show();
                    $idinfo = $('#contract_receivables').data('id');
                    if($idinfo == 1){
                        $("#seven .btn-refresh").trigger("click");
                        return ;
                    }
                    $('#contract_receivables').data('id',1);
                }else if(type == 8){
                    $('#contract_achievement').show();
                    $idinfo = $('#contract_achievement').data('id');
                    if($idinfo == 1){
                        $("#fives .btn-refresh").trigger("click");
                        return ;
                    }
                    $('#contract_achievement').data('id',1);
                }else if(type == 9){
                    $('#contract_quote').show();
                    $idinfo = $('#contract_quote').data('id');
                    if($idinfo == 1){
                        $("#quotecheck .btn-refresh").trigger("click");
                        return ;
                    }
                    $('#contract_quote').data('id',1);
                }else if(type == 10){
                    $('#contract_consume').show();
                    $idinfo = $('#contract_consume').data('id');
                    if($idinfo == 1){
                        $("#thirds .btn-refresh").trigger("click");
                        return ;
                    }
                    $('#contract_consume').data('id',1);
                }else if(type == 11){
                    $('#contract_work').show();
                    $idinfo = $('#contract_work').data('id');
                    if($idinfo == 1){
                        $("#nine .btn-refresh").trigger("click");
                        return ;
                    }
                    $('#contract_work').data('id',1);
                }else if(type == 13){
                    $('#contract').show();
                    $idinfo = $('#contract').data('id');
                    if($idinfo == 1){
                        $("#five1 .btn-refresh").trigger("click");
                        return ;
                    }


                    $('#contract').data('id',1);
                }else if(type == 15){
                    $('#contract_invoice').show();
                    $idinfo = $('#contract_invoice').data('id');
                    if($idinfo == 1){
                        $("#invoicecheck .btn-refresh").trigger("click");
                        return ;
                    }
                    $('#contract_invoice').data('id',1);
                }else if(type == 27){
                    $('#delivery').show();
                    $idinfo = $('#delivery').data('id');
                    if($idinfo == 1){
                        $("#deliverycheck .btn-refresh").trigger("click");
                        return ;
                    }
                    $('#delivery').data('id',1);
                }else if(type == 29){
                    $('#instock').show();
                    $idinfo = $('#instock').data('id');
                    if($idinfo == 1){
                        $("#instockcheck .btn-refresh").trigger("click");
                        return ;
                    }
                    $('#instock').data('id',1);
                }else if(type == 31){
                    $('#outstock').show();
                    $idinfo = $('#outstock').data('id');
                    if($idinfo == 1){
                        $("#outstockcheck .btn-refresh").trigger("click");
                        return ;
                    }
                    $('#outstock').data('id',1);
                }


            });
            //消息
            $(document).on('click', '.show-detail', function (data) {
                var types = $(this).data('type');
                var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
                var options = {
                    shadeClose : false,
                    shade      : [0.3, '#393D49'],
                    area       : area,
                    callback   : function (value) {
                        //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                    },
                    success   : function (value) {
                        get_need_number();
                        $("#one .btn-refresh").trigger("click");
                        //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                    },
                };

                $urls = '';
                $names ='';
                if(types =='consume'){
                    $urls = "qingdongwms/customer/consume/detail?ids=" + $(this).data('id');
                    $names ='费用';
                }else if(types =='contract'){
                    $urls = "qingdongwms/customer/contract/detail?ids=" + $(this).data('id');
                    $names ='合同';
                }else if(types =='record' || types =='comment' || types =='sign'){
                    $urls = "qingdongwms/customer/record/detail?ids=" + $(this).data('id');
                    $names ='跟进记录';
                }else if(types =='receivables'){
                    $urls = "qingdongwms/customer/receivables/detail?ids=" + $(this).data('id');
                    $names ='回款';
                }else if(types =='customer'){
                    $urls = "qingdongwms/customer/customer/detail?ids=" + $(this).data('id');
                    $names ='客户';
                }else if(types =='quote'){
                    $urls = "qingdongwms/customer/quote/detail?ids=" + $(this).data('id');
                    $names ='报价';
                }else if(types =='daily'){
                    $urls = "qingdongwms/report/daily/detail?ids=" + $(this).data('id')+'&types='+types;
                    $names ='工作报告';
                }else if(types =='achievement'){
                    $urls = "qingdongwms/department/achievement/detail?ids=" + $(this).data('id');
                    $names ='业绩';
                }else if(types=='approval'){
                    $urls = "qingdongwms/work/approval/detail?ids=" + $(this).data('id');
                    $names ='办公';
                }else if(types=='event'){
                    $urls = "qingdongwms/event/event/detail?ids=" + $(this).data('id');
                    $names ='任务';
                }else if(types=='instock'){
                    $urls = "qingdongwms/stock/instock/detail?ids=" + $(this).data('id');
                    $names ='入库';
                }else if(types=='outstock'){
                    $urls = "qingdongwms/stock/outstock/detail?ids=" + $(this).data('id');
                    $names ='出库';
                }else if(types=='delivery'){
                    $urls = "qingdongwms/customer/delivery/detail?ids=" + $(this).data('id');
                    $names ='发货';
                }else{
                    return;
                }
                Fast.api.open($urls, $names, options);
            });
            //公告
            $(document).on('click', '.show-detail_notice', function (data) {
                var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
                var options = {
                    shadeClose : false,
                    shade      : [0.3, '#393D49'],
                    area       : area,
                    callback   : function (value) {
                    },
                    success   : function (value) {
                        get_need_number();
                        $("#two .btn-refresh").trigger("click");
                    },
                };

                $urls = "qingdongwms/notice/notice/detail?ids=" + $(this).data('id');
                $names ='公告';
                Fast.api.open($urls, $names, options);
            });
            //线索、客户、商机跟进
            $(document).on('click', '.show-leads', function (data) {
                var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
                var options = {
                    shadeClose : false,
                    shade      : [0.3, '#393D49'],
                    area       : area,
                    callback   : function (value) {

                    },

                };
                var types = $(this).data('type');
                $urls = '';
                $names ='';
                if(types == 1){
                    $urls = "qingdongwms/customer/customer/detail?ids=" + $(this).data('id');
                    $names ='客户';
                }else if(types == 4){
                    $urls = "qingdongwms/customer/leads/detail?ids=" + $(this).data('id');
                    $names ='线索';
                }else if(types == 5){
                    $urls = "qingdongwms/customer/business/detail?ids=" + $(this).data('id');
                    $names ='商机';
                }else{
                    return;
                }

                Fast.api.open($urls, $names, options);
            });
        },
        table: {
            // 消息提醒
            news: function () {
                var table1 = $("#table");
                table1.bootstrapTable({
                    url: 'qingdongwms/customer/need/news',
                    toolbar: '#toolbar',
                    sortName: 'id',
                    search: false,
                    searchFormVisible:true,
                    columns: [
                        [
                            {field: 'relation_name', title: __('消息名称'),operate:false, fixedColumns : true, formatter : function (value, row, index) {
                                    if(value ==''){
                                        return '';
                                    }
                                    return "<a href='javascript:void(0);' data-id='" + row.relation_id + "' data-type='" + row.relation_type + "' class='show-detail'>" + value + "</a>";
                                }
                            },
                            {field: 'content', title: __('消息内容'),operate:false},
                            {field: 'send_time', title: __('消息时间'),operate:false},
                            {field : 'status', title : '状态',operate:'=',searchList:{0:'未读',1:'已读'},formatter:Table.api.formatter.status,defaultValue:0},
                            {field: 'from_staff.name', title: __('发送人'),operate:false},
                        ]
                    ]
                });

                // 为表格1绑定事件
                Table.api.bindevent(table1);
            },
            //公告
            notice: function () {

                // 表格2
                var table2 = $("#table1");
                table2.bootstrapTable({
                    url: 'qingdongwms/customer/need/notice',
                    toolbar: '#toolbar1',
                    sortName: 'id',
                    search: false,
                    searchFormVisible:true,
                    columns: [
                        [
                            {field: 'title', title: __('标题'), fixedColumns : true, formatter : function (value, row, index) {
                                    if(value ==''){
                                        return '';
                                    }
                                    return "<a href='javascript:void(0);' data-id='" + row.id + "'  class='show-detail_notice'>" + value + "</a>";
                                }
                            },
                            {field : 'is_read', title : '状态',operate:false,searchList:{1:'未读',0:'已读'},formatter:Table.api.formatter.status},
                            {field: 'content', title: __('内容'),operate:false},
                            {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        ]
                    ]
                });
                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },
            //待审核合同
            contract_examine: function () {
                Controller.table['first'].call(this);
            },
            //待审核发票
            contract_invoice: function () {
                Controller.table['invoicecheck'].call(this);
            },
            //待审核合同
            first: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/index?status=0',
                        table: 'contact'
                    }
                });
                // 合同
                var table1 = $("#table5");
                table1.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar5',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field: 'state', checkbox: true, },
                            {field : 'contract.owner_staff.name', title : __('提交人'), operate: false},

                            {
                                field : 'contract.name', title : '合同名称', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.contract){
                                        return "<a href='javascript:void(0);' data-id='" + row.contract.id + "' class='show-contract'>" + value + "</a>";
                                    }
                                    return '';
                                },operate:false
                            },
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'content', title: __('审批内容')},
                            {field: 'check_time', title: __('审批时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'operate', title: __('Operate'), table: table1, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        area:'',

                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=contract&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback: function (data) {
                                            get_need_number();
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=contract&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback: function (data) {
                                            get_need_number();
                                        },
                                    },
                                ]
                            }
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });
                $(document).on('click', '.show-contract', function (data) {
                    var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
                    var options = {
                        shadeClose : false,
                        shade      : [0.3, '#393D49'],
                        area       : area,
                        end   : function (value) {
                            //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                            // $(".btn-refresh").trigger("click");
                        }
                    };
                    Fast.api.open("qingdongwms/customer/contract/detail?ids=" + $(this).data('id'), '合同', options);
                });
                // 为表格1绑定事件
                Table.api.bindevent(table1);

            },
            //待审核合同-我已审批的
            second: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/index?status=1',
                        table: 'contact'
                    }
                });
                // 合同
                var table1 = $("#table6");
                table1.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar6',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field: 'state', checkbox: true, },
                            {field : 'contract.owner_staff.name', title : __('提交人'), operate: false},

                            {
                                field : 'contract.name', title : '合同名称', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.contract){
                                        return "<a href='javascript:void(0);' data-id='" + row.contract.id + "' class='show-contract'>" + value + "</a>";
                                    }
                                    return '';
                                },operate:false
                            },
                            {field: 'contract.name', title: '合同名称', operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'content', title: __('审批内容')},
                            {field: 'check_time', title: __('审批时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                // 为表格1绑定事件
                Table.api.bindevent(table1);
            },
            //待审核费用
            contract_consume: function () {
                Controller.table['thirds'].call(this);
            },
            //待审核费用-待我审批的
            thirds: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/consume?status=0',
                        table: 'consume'
                    }
                });
                // 费用
                var table2 = $("#table13");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar13',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field : 'consume.staff.name', title : __('提交人'), operate: false},
                            {field: 'consume.number', title: __('报销单号'), operate:false, formatter : function (value, row, index) {
                                    if(row.consume){
                                        return "<a href='javascript:void(0);' class='btn-dialog show-detail'  data-shade=\"0.3\"\n" +
                                            "data-url=\"qingdongwms/customer/consume/detail?ids=" + row.consume.id+
                                            "\" data-title=\"费用详情\" ' >" + value + "</a>";
                                    }
                                    return '';
                                }},
                            {field: 'consume.submit_date', title: __('消费日期'), operate:false, addclass: 'datetimepicker',data:"data-date-format=\" YYYY-MM-DD\""},

                            {field: 'consume.customer', title: __('关联客户'), operate:false, formatter : function (value, row, index) {
                                    if(row.consume.customer){
                                        return "<a href='javascript:void(0);' data-id='" + row.consume.customer.id + "' class='show-customer'>" + row.consume.customer.name + "</a>";
                                    }else{
                                        return '';
                                    }
                                }},

                            {field: 'consume.money', title: __('消费金额'),operate:false},
                            {field: 'consume.remark', title: __('备注'),operate:false},

                            {field: 'consume.staff.name', title: __('提交人'),operate:false},

                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'operate', title: __('Operate'), table: table2, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        area:'',
                                        refresh:true,
                                        icon: 'fa fa-check',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=consume&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();

                                        },

                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        icon: 'fa fa-close',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=consume&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            console.log(data, ret);
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();

                                        },

                                    },
                                ]
                            }

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                $(document).on('click', '.show-consume', function (data) {
                    var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
                    var options = {
                        shadeClose : false,
                        shade      : [0.3, '#393D49'],
                        area       : area,
                        end   : function (value) {
                            //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                            console.log(value);
                            $(".btn-refresh").trigger("click");
                        }
                    };
                    Fast.api.open("qingdongwms/customer/consume/detail?ids=" + $(this).data('id'), '费用详情', options);
                });
                // 为表格2绑定事件
                Table.api.bindevent(table2);

            },
            //待审核费用-我已审批的
            fours: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/consume?status=1',
                        table: 'consume'
                    }
                });
                // 费用
                var table2 = $("#table14");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar14',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field : 'consume.staff.name', title : __('提交人'), operate: false},
                            {field: 'consume.number', title: __('报销单号'), operate:false, formatter : function (value, row, index) {
                                if(row.consume){
                                    return "<a href='javascript:void(0);' class='btn-dialog show-detail'  data-shade=\"0.3\"\n" +
                                        "data-url=\"qingdongwms/customer/consume/detail?ids=" + row.consume.id+
                                        "\" data-title=\"费用详情\" ' >" + value + "</a>";
                                }
                                return '';

                                }},
                            {field: 'consume.submit_date', title: __('消费日期'), operate: false, addclass: 'datetimepicker',data:"data-date-format=\" YYYY-MM-DD\""},

                            {field: 'consume.customer', title: __('关联客户'), operate:false, formatter : function (value, row, index) {
                                    if(row.consume){
                                        return "<a href='javascript:void(0);' data-id='" + row.consume.customer.id + "' class='show-customer'>" + row.consume.customer.name + "</a>";
                                    }else{
                                        return '';
                                    }
                                }},

                            {field: 'consume.money', title: __('消费金额'),operate:false},
                            {field: 'consume.remark', title: __('备注'),operate:false},

                            {field: 'consume.staff.name', title: __('提交人'),operate:false},

                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },

            //待审核业绩
            contract_achievement: function () {
                Controller.table['fives'].call(this);
            },
            //待审核业绩-待我审批的
            fives: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/achievement?status=0',
                        table: 'achievement'
                    }
                });
                // 业绩目标
                var table4 = $("#table9");
                table4.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar9',
                    sortName: 'id',

                    search: false,
                    columns: [
                        [
                            {field : 'check_staff.name', title : __('提交人'), operate: false},
                            {field: 'achievement.status', title: '业绩目标类型', operate: false, formatter : Table.api.formatter.status, searchList :{1:'获客',2:'拜访',3: '合同金额', 4: '回款金额'}},
                            {field: 'achievement.year', title: '业绩目标年份', operate: false},
                            {field: 'achievement.yeartarget', title: '年目标', operate: false},
                            {field : 'achievement.january', title : __('一月'), operate: false},
                            {field : 'achievement.february', title : __('二月'), operate: false},
                            {field : 'achievement.march', title : __('三月'), operate: false},
                            {field : 'achievement.april', title : __('四月'), operate: false},
                            {field : 'achievement.may', title : __('五月'), operate: false},
                            {field : 'achievement.june', title : __('六月'), operate: false},
                            {field : 'achievement.july', title : __('七月'), operate: false},
                            {field : 'achievement.august', title : __('八月'), operate: false},
                            {field : 'achievement.september', title : __('九月'), operate: false},
                            {field : 'achievement.october', title : __('十月'), operate: false},
                            {field : 'achievement.november', title : __('十一月'), operate: false},
                            {field : 'achievement.december', title : __('十二月'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'operate', title: __('Operate'), table: table4, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=achievement&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=achievement&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            console.log(data, ret);
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                ]
                            }
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });
                // 为表格2绑定事件
                Table.api.bindevent(table4);
            },
            //待审核业绩-我已审批的
            sixs: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/achievement?status=1',
                        table: 'achievement'
                    }
                });
                // 业绩目标
                var table4 = $("#table10");
                table4.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar10',
                    sortName: 'id',
                    fixedColumns : true,
                    fixedRightNumber  : 1,
                    search: false,
                    columns: [
                        [
                            {field : 'check_staff.name', title : __('提交人'), operate: false},
                            {field: 'achievement.status', title: '业绩目标类型', operate: false, formatter : Table.api.formatter.status, searchList :{1:'获客',2:'拜访',3: '合同金额', 4: '回款金额'}},
                            {field: 'achievement.year', title: '业绩目标年份', operate: false},
                            {field: 'achievement.yeartarget', title: '年目标', operate: false},
                            {field : 'achievement.january', title : __('一月'), operate: false},
                            {field : 'achievement.february', title : __('二月'), operate: false},
                            {field : 'achievement.march', title : __('三月'), operate: false},
                            {field : 'achievement.april', title : __('四月'), operate: false},
                            {field : 'achievement.may', title : __('五月'), operate: false},
                            {field : 'achievement.june', title : __('六月'), operate: false},
                            {field : 'achievement.july', title : __('七月'), operate: false},
                            {field : 'achievement.august', title : __('八月'), operate: false},
                            {field : 'achievement.september', title : __('九月'), operate: false},
                            {field : 'achievement.october', title : __('十月'), operate: false},
                            {field : 'achievement.november', title : __('十一月'), operate: false},
                            {field : 'achievement.december', title : __('十二月'), operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });
                // 为表格2绑定事件
                Table.api.bindevent(table4);
            },

            //待审核回款
            contract_receivables: function () {
                Controller.table['seven'].call(this);
            },
            seven: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/receivables?status=0',
                        table: 'receivables'
                    }
                });
                // 回款
                var table3 = $("#table7");
                table3.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar7',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field : 'receivables.create_staff.name', title : __('提交人'), operate: false},

                            {
                                field : 'receivables.number', title : '回款编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.receivables){
                                        if(!row.receivables.number){
                                            return "<a href='javascript:void(0);' data-id='" + row.relation_id + "' class='show-receivables'>--</a>";
                                        }
                                        return "<a href='javascript:void(0);' data-id='" + row.relation_id + "' class='show-receivables'>" + row.receivables.number + "</a>";
                                    }
                                    return '';
                                },operate:false
                            },
                            {field: 'receivables.return_type', title: '回款方式', operate: false},
                            {field: 'receivables.return_time', title: '回款日期', operate: false},
                            {field: 'receivables.money', title: '回款金额', operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'operate', title: __('Operate'), table: table3, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:false,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=receivables&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=receivables&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                ]
                            }
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });
                $(document).on('click', '.show-receivables', function (data) {
                    var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
                    var options = {
                        shadeClose : false,
                        shade      : [0.3, '#393D49'],
                        area       : area,
                        end   : function (value) {
                            //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                            //  $(".btn-refresh").trigger("click");
                        }
                    };
                    Fast.api.open("qingdongwms/customer/receivables/detail?ids=" + $(this).data('id'), '回款详情', options);
                });

                // 为表格2绑定事件
                Table.api.bindevent(table3);
            },
            eight: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/receivables?status=1',
                        table: 'receivables'
                    }
                });
                // 回款
                var table3 = $("#table8");
                table3.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar8',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field : 'receivables.create_staff.name', title : __('提交人'), operate: false},

                            {
                                field : 'receivables.number', title : '回款编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.receivables){
                                        if(!row.receivables.number){
                                            return "<a href='javascript:void(0);' data-id='" + row.relation_id + "' class='show-receivables'>--</a>";
                                        }
                                        return "<a href='javascript:void(0);' data-id='" + row.relation_id + "' class='show-receivables'>" + row.receivables.number + "</a>";
                                    }
                                    return '';
                                },operate:false
                            },
                            {field: 'receivables.return_type', title: '回款方式', operate: false},
                            {field: 'receivables.return_time', title: '回款日期', operate: false},
                            {field: 'receivables.money', title: '回款金额', operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                // 为表格2绑定事件
                Table.api.bindevent(table3);
            },

            //工作审批
            contract_work: function () {
                Controller.table['nine'].call(this);
            },
            nine: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/work?status=0',
                        table: 'work'
                    }
                });
                // 办公审批
                var table3 = $("#table15");
                table3.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,

                    toolbar: '#toolbar15',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field: 'approval_name', title: __('审批类型'), operate: false},
                            {field : 'approval.create_staff.name', title : __('提交人'), operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'operate', title: __('Operate'), table: table3, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'detail',
                                        text: __('详情'),
                                        classname: 'records btn-dialog',
                                        url: function (row) {
                                            return 'qingdongwms/work/approval/detail?ids=' + row.approval.id;
                                        },
                                        extend: "data-area='[\"80%\", \"80%\"]'",
                                        callback: function (data) {
                                            Layer.alert("接收到回传数据：" + JSON.stringify(data), {title: "回传数据"});
                                            $(".btn-refresh").trigger("click");
                                        }
                                    },
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=approval&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=approval&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            console.log(data, ret);
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                ]
                            }
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });


                // 为表格2绑定事件
                Table.api.bindevent(table3);
            },
            ten: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/work?status=1',
                        table: 'work'
                    }
                });
                // 办公审批
                var table3 = $("#table16");
                table3.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,

                    toolbar: '#toolbar16',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field: 'approval_name', title: __('审批类型'), operate: false},
                            {field : 'approval.create_staff.name', title : __('提交人'), operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'operate', title: __('Operate'), table: table3, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'detail',
                                        text: __('详情'),
                                        classname: 'records btn-dialog',
                                        url: function (row) {
                                            return 'qingdongwms/work/approval/detail?ids=' + row.approval.id;
                                        },
                                        extend: "data-area='[\"80%\", \"80%\"]'",
                                        callback: function (data) {
                                            Layer.alert("接收到回传数据：" + JSON.stringify(data), {title: "回传数据"});
                                            $(".btn-refresh").trigger("click");
                                        }
                                    },
                                ]
                            }
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });
                // 为表格2绑定事件
                Table.api.bindevent(table3);
            },

            //待审核报价单
            contract_quote: function () {
                Controller.table['quotecheck'].call(this);
            },
            quotecheck: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/quote?status=0',
                        table: 'work'
                    }
                });
                // 办公审批
                var table = $("#table11");
                table.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,

                    toolbar: '#toolbar11',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field: 'state', checkbox: true, },
                            {field : 'quote.owner_staff.name', title : __('提交人'), operate:false,searchList:$.getJSON("qingdongwms/customer/customer/stafflist")},
                            {
                                field : 'quote.number', title : '报价单编号', fixedColumns : true, formatter : function (value, row, index) {

                                    return "<a href='javascript:void(0);' data-area=[\"95%\",\"95%\"] class='btn-dialog show-detail' " +
                                        "data-url='qingdongwms/customer/quote/detail/ids/"+row.quote.id+"' data-shade='0.3' data-title='报价单详情' >" + value + "</a>";
                                },operate:false
                            },
                            {
                                field : 'quote.customer.name', title : '客户信息', fixedColumns : true, formatter : function (value, row, index) {

                                    return "<a href='javascript:void(0);' data-area=[\"95%\",\"95%\"] class='btn-dialog' " +
                                        "data-url='qingdongwms/customer/customer/detail/ids/"+row.quote.customer.id+"' data-shade='0.3' data-title='客户详情' >" + row.quote.customer.name  + "</a>";
                                },operate:false
                            },
                            {field: 'quote.quote_amount', title: '报价金额', operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate:'=', formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-ajax',
                                        confirm: '确认要审核通过当前报价单?',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=quote&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-ajax',
                                        confirm: '确认要拒绝通过当前报价单?',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=quote&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            console.log(data, ret);
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                ]
                            }
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });
                // 为表格2绑定事件
                Table.api.bindevent(table);
            },
            quotesuccess: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/quote?status=1',
                        table: 'work'
                    }
                });
                // 办公审批
                var table = $("#table12");
                table.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar12',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field: 'state', checkbox: true, },
                            {field : 'quote.owner_staff.name', title : __('提交人'), operate:false,searchList:$.getJSON("qingdongwms/customer/customer/stafflist")},

                            {
                                field : 'quote.number', title : '报价单编号', fixedColumns : true, formatter : function (value, row, index) {

                                    return "<a href='javascript:void(0);' data-area=[\"95%\",\"95%\"] class='btn-dialog show-detail' " +
                                        "data-url='qingdongwms/customer/quote/detail/ids/"+row.quote.id+"' data-shade='0.3' data-title='报价单详情' >" + value + "</a>";
                                },operate:false
                            },
                            {
                                field : 'quote.customer.name', title : '客户信息', fixedColumns : true, formatter : function (value, row, index) {

                                    return "<a href='javascript:void(0);' data-area=[\"95%\",\"95%\"] class='btn-dialog' " +
                                        "data-url='qingdongwms/customer/customer/detail/ids/"+row.quote.customer.id+"' data-shade='0.3' data-title='客户详情' >" + row.quote.customer.name  + "</a>";
                                },operate:false
                            },
                            {field: 'quote.quote_amount', title: '报价金额', operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate:'=', formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });
                // 为表格2绑定事件
                Table.api.bindevent(table);
            },

            //出库/入库
            contract_stock: function () {
                Controller.table['nostock'].call(this);
            },

            //线索
            leads: function () {
                Controller.table['lead_first'].call(this);
            },
            lead_first : function () {
                // 初始化表格参数配置
                Table.api.init({
                });

                var table2 = $("#table2");
                table2.bootstrapTable({
                    url: 'qingdongwms/customer/need/leads?type=1',
                    toolbar: '#toolbar2',
                    sortName: 'id',
                    columns: [
                        [
                            {
                                field : 'leads.name', title : '线索名称', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.leads){
                                        return "<a href='javascript:void(0);' data-id='" + row.leads.id + "' data-type='4' class='show-leads'>" + row.leads.name + "</a>";
                                    }else{
                                        return '';
                                    }

                                },operate:false
                            },
                            {field: 'follow_type', title: __('跟进类型')},
                            {field: 'follow_time', title: __('跟进时间'), operate:'RANGE', addclass:'datetimerange',defaultValue:Config.info.time},
                            {field: 'follow', title: __('跟进状态')},
                            {field: 'content', title: __('跟进内容')},
                            {field: 'next_time', title: __('下次跟进时间'), operate:'RANGE', addclass:'datetimerange'},
                            {field: 'staff.name', title: __('创建人'),operate:false},
                            {
                                field     : 'operate',
                                title     : __('Operate'),
                                table     : table2,
                                events    : Table.api.events.operate,
                                formatter : Table.api.formatter.operate,
                                buttons   : [
                                    {
                                        name      : '详情',
                                        text      : __('详情'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/record/detail',
                                        callback: function (data) {
                                            $('.btn-success').trigger('click');
                                        },

                                    },
                                    {
                                        name      : '评论',
                                        text      : __('评论'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/comment/add',
                                        callback: function (data) {

                                            get_need_number();

                                        },

                                    }
                                ]
                            }
                        ]
                    ],
                    pagination        : true,
                    search            : false,
                    commonSearch      : true,
                    searchFormVisible : true,
                    //显示导出按钮
                    showExport: false,
                });
                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },
            lead_second : function () {
                // 初始化表格参数配置
                Table.api.init({
                });

                var table2 = $("#table21");
                table2.bootstrapTable({
                    url: 'qingdongwms/customer/need/leads?type=2',
                    toolbar: '#toolbar21',
                    sortName: 'id',
                    columns: [
                        [
                            {
                                field : 'leads.name', title : '线索名称', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.leads){
                                        return "<a href='javascript:void(0);' data-id='" + row.leads.id + "' data-type='4' class='show-leads'>" + row.leads.name + "</a>";
                                    }else{
                                        return '';
                                    }

                                },operate:false
                            },
                            {field: 'follow_type', title: __('跟进类型')},
                            {field: 'follow_time', title: __('跟进时间'), operate:'RANGE', addclass:'datetimerange',defaultValue:Config.info.time},
                            {field: 'follow', title: __('跟进状态')},
                            {field: 'content', title: __('跟进内容')},
                            {field: 'next_time', title: __('下次跟进时间'), operate:'RANGE', addclass:'datetimerange'},
                            {field: 'staff.name', title: __('创建人'),operate:false},
                            {
                                field     : 'operate',
                                title     : __('Operate'),
                                table     : table2,
                                events    : Table.api.events.operate,
                                formatter : Table.api.formatter.operate,
                                buttons   : [
                                    {
                                        name      : '详情',
                                        text      : __('详情'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/record/detail',
                                        callback: function (data) {
                                            $('.btn-success').trigger('click');
                                        },

                                    },
                                    {
                                        name      : '评论',
                                        text      : __('评论'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/comment/add',
                                        callback: function (data) {

                                            get_need_number();

                                        },

                                    }
                                ]
                            }
                        ]
                    ],
                    pagination        : true,
                    search            : false,
                    commonSearch      : true,
                    searchFormVisible : true,
                    //显示导出按钮
                    showExport: false,
                });
                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },

            //客户
            customer: function () {
                Controller.table['customer_first'].call(this);
            },
            customer_first : function () {
                // 初始化表格参数配置
                Table.api.init({
                });

                // 表格2
                var table2 = $("#table3");
                table2.bootstrapTable({
                    url: 'qingdongwms/customer/need/customer?type=1',
                    toolbar: '#toolbar3',
                    sortName: 'id',
                    search: false,
                    searchFormVisible:true,
                    columns: [
                        [
                            {
                                field : 'customer.name', title : '客户名称', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.customer){
                                        return "<a href='javascript:void(0);' data-id='" + row.customer.id + "' data-type='1' class='show-leads'>" + row.customer.name + "</a>";
                                    }else{
                                        return '';
                                    }

                                },operate:false
                            },
                            {field: 'follow_type', title: __('跟进类型')},
                            {field: 'follow_time', title: __('跟进时间'), operate:'RANGE', addclass:'datetimerange'},
                            {field: 'follow', title: __('跟进状态')},
                            {field: 'content', title: __('跟进内容')},
                            {field: 'next_time', title: __('下次跟进时间'), operate:'RANGE', addclass:'datetimerange',defaultValue:Config.info.time},
                            {field: 'staff.name', title: __('创建人'),operate:false},
                            {
                                field     : 'operate',
                                title     : __('Operate'),
                                table     : table2,
                                events    : Table.api.events.operate,
                                formatter : Table.api.formatter.operate,
                                buttons   : [
                                    {
                                        name      : '详情',
                                        text      : __('详情'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/record/detail',
                                        callback: function (data) {
                                            $('.btn-success').trigger('click');
                                        },

                                    },
                                    {
                                        name      : '评论',
                                        text      : __('评论'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/comment/add',
                                        callback: function (data) {
                                            get_need_number();
                                        },

                                    }
                                ]
                            }
                        ]
                    ],
                });
                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },
            customer_second : function () {
                // 初始化表格参数配置
                Table.api.init({
                });

                // 表格2
                var table2 = $("#table22");
                table2.bootstrapTable({
                    url: 'qingdongwms/customer/need/customer?type=2',
                    toolbar: '#toolbar22',
                    sortName: 'id',
                    search: false,
                    searchFormVisible:true,
                    columns: [
                        [
                            {
                                field : 'customer.name', title : '客户名称', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.customer){
                                        return "<a href='javascript:void(0);' data-id='" + row.customer.id + "' data-type='1' class='show-leads'>" + row.customer.name + "</a>";
                                    }else{
                                        return '';
                                    }

                                },operate:false
                            },
                            {field: 'follow_type', title: __('跟进类型')},
                            {field: 'follow_time', title: __('跟进时间'), operate:'RANGE', addclass:'datetimerange'},
                            {field: 'follow', title: __('跟进状态')},
                            {field: 'content', title: __('跟进内容')},
                            {field: 'next_time', title: __('下次跟进时间'), operate:'RANGE', addclass:'datetimerange',defaultValue:Config.info.time},
                            {field: 'staff.name', title: __('创建人'),operate:false},
                            {
                                field     : 'operate',
                                title     : __('Operate'),
                                table     : table2,
                                events    : Table.api.events.operate,
                                formatter : Table.api.formatter.operate,
                                buttons   : [
                                    {
                                        name      : '详情',
                                        text      : __('详情'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/record/detail',
                                        callback: function (data) {
                                            $('.btn-success').trigger('click');
                                        },

                                    },
                                    {
                                        name      : '评论',
                                        text      : __('评论'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/comment/add',
                                        callback: function (data) {
                                            get_need_number();
                                        },

                                    }
                                ]
                            }
                        ]
                    ],
                });
                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },

            //商机
            business: function () {
                Controller.table['business_first'].call(this);
            },
            business_first : function () {
                // 初始化表格参数配置
                Table.api.init({
                });

                // 表格2
                var table2 = $("#table4");
                table2.bootstrapTable({
                    url: 'qingdongwms/customer/need/business?type=1',
                    toolbar: '#toolbar4',
                    sortName: 'id',
                    search: false,
                    searchFormVisible:true,
                    columns: [
                        [
                            {
                                field : 'business.name', title : '商机名称', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.business){
                                        return "<a href='javascript:void(0);' data-id='" + row.business.id + "' data-type='5' class='show-leads'>" + row.business.name + "</a>";
                                    }else{
                                        return '';
                                    }

                                },operate:false
                            },
                            {field: 'follow_type', title: __('跟进类型')},
                            {field: 'follow_time', title: __('跟进时间'), operate:'RANGE', addclass:'datetimerange'},
                            {field: 'follow', title: __('跟进状态')},
                            {field: 'content', title: __('跟进内容')},
                            {field: 'next_time', title: __('下次跟进时间'), operate:'RANGE', addclass:'datetimerange',defaultValue:Config.info.time},
                            {field: 'staff.name', title: __('创建人'),operate:false},
                            {
                                field     : 'operate',
                                title     : __('Operate'),
                                table     : table2,
                                events    : Table.api.events.operate,
                                formatter : Table.api.formatter.operate,
                                buttons   : [
                                    {
                                        name      : '详情',
                                        text      : __('详情'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/record/detail',
                                        callback: function (data) {
                                            $('.btn-success').trigger('click');
                                        },

                                    },
                                    {
                                        name      : '评论',
                                        text      : __('评论'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/comment/add',
                                        callback: function (data) {
                                            get_need_number();
                                        },

                                    }
                                ]
                            }
                        ]
                    ],
                });
                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },
            business_second : function () {
                // 初始化表格参数配置
                Table.api.init({
                });

                // 表格2
                var table2 = $("#table23");
                table2.bootstrapTable({
                    url: 'qingdongwms/customer/need/business?type=2',
                    toolbar: '#toolbar23',
                    sortName: 'id',
                    search: false,
                    searchFormVisible:true,
                    columns: [
                        [
                            {
                                field : 'business.name', title : '商机名称', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.business){
                                        return "<a href='javascript:void(0);' data-id='" + row.business.id + "' data-type='5' class='show-leads'>" + row.business.name + "</a>";
                                    }else{
                                        return '';
                                    }

                                },operate:false
                            },
                            {field: 'follow_type', title: __('跟进类型')},
                            {field: 'follow_time', title: __('跟进时间'), operate:'RANGE', addclass:'datetimerange'},
                            {field: 'follow', title: __('跟进状态')},
                            {field: 'content', title: __('跟进内容')},
                            {field: 'next_time', title: __('下次跟进时间'), operate:'RANGE', addclass:'datetimerange',defaultValue:Config.info.time},
                            {field: 'staff.name', title: __('创建人'),operate:false},
                            {
                                field     : 'operate',
                                title     : __('Operate'),
                                table     : table2,
                                events    : Table.api.events.operate,
                                formatter : Table.api.formatter.operate,
                                buttons   : [
                                    {
                                        name      : '详情',
                                        text      : __('详情'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/record/detail',
                                        callback: function (data) {
                                            $('.btn-success').trigger('click');
                                        },

                                    },
                                    {
                                        name      : '评论',
                                        text      : __('评论'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/comment/add',
                                        callback: function (data) {
                                            get_need_number();
                                        },

                                    }
                                ]
                            }
                        ]
                    ],
                });
                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },

            //合同
            contract: function () {
                Controller.table['contract_first'].call(this);
            },
            contract_first : function () {
                // 初始化表格参数配置
                Table.api.init({
                });

                // 表格2
                var table2 = $("#table19");
                table2.bootstrapTable({
                    url: 'qingdongwms/customer/need/contract?type=1',
                    toolbar: '#toolbar19',
                    sortName: 'id',
                    search: false,
                    searchFormVisible:true,
                    columns: [
                        [
                            {
                                field : 'contract.name', title : '合同名称', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.contract){
                                        return "<a href='javascript:void(0);' data-id='" + row.contract.id + "' data-type='contract' class='show-detail'>" + row.contract.name + "</a>";
                                    }else{
                                        return '';
                                    }

                                },operate:false
                            },
                            {field: 'follow_type', title: __('跟进类型')},
                            {field: 'follow_time', title: __('跟进时间'), operate:'RANGE', addclass:'datetimerange',defaultValue:Config.info.time},
                            {field: 'follow', title: __('跟进状态')},
                            {field: 'content', title: __('跟进内容')},
                            {field: 'next_time', title: __('下次跟进时间'), operate:'RANGE', addclass:'datetimerange'},
                            {field: 'staff.name', title: __('创建人'),operate:false},
                            {
                                field     : 'operate',
                                title     : __('Operate'),
                                table     : table2,
                                events    : Table.api.events.operate,
                                formatter : Table.api.formatter.operate,
                                buttons   : [
                                    {
                                        name      : '详情',
                                        text      : __('详情'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/record/detail',
                                        callback: function (data) {
                                            $('.btn-success').trigger('click');
                                        },

                                    },
                                    {
                                        name      : '评论',
                                        text      : __('评论'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/comment/add',
                                        callback: function (data) {
                                            get_need_number();
                                        },

                                    }
                                ]
                            }
                        ]
                    ],
                });
                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },
            contract_second : function () {
                // 初始化表格参数配置
                Table.api.init({
                });

                // 表格2
                var table2 = $("#table24");
                table2.bootstrapTable({
                    url: 'qingdongwms/customer/need/contract?type=2',
                    toolbar: '#toolbar24',
                    sortName: 'id',
                    search: false,
                    searchFormVisible:true,
                    columns: [
                        [
                            {
                                field : 'contract.name', title : '合同名称', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.contract){
                                        return "<a href='javascript:void(0);' data-id='" + row.contract.id + "' data-type='contract' class='show-detail'>" + row.contract.name + "</a>";
                                    }else{
                                        return '';
                                    }

                                },operate:false
                            },
                            {field: 'follow_type', title: __('跟进类型')},
                            {field: 'follow_time', title: __('跟进时间'), operate:'RANGE', addclass:'datetimerange',defaultValue:Config.info.time},
                            {field: 'follow', title: __('跟进状态')},
                            {field: 'content', title: __('跟进内容')},
                            {field: 'next_time', title: __('下次跟进时间'), operate:'RANGE', addclass:'datetimerange'},
                            {field: 'staff.name', title: __('创建人'),operate:false},
                            {
                                field     : 'operate',
                                title     : __('Operate'),
                                table     : table2,
                                events    : Table.api.events.operate,
                                formatter : Table.api.formatter.operate,
                                buttons   : [
                                    {
                                        name      : '详情',
                                        text      : __('详情'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/record/detail',
                                        callback: function (data) {
                                            $('.btn-success').trigger('click');
                                        },

                                    },
                                    {
                                        name      : '评论',
                                        text      : __('评论'),
                                        classname : 'records btn-dialog',
                                        url       : 'qingdongwms/customer/comment/add',
                                        callback: function (data) {
                                            get_need_number();
                                        },

                                    }
                                ]
                            }
                        ]
                    ],
                });
                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },
            invoicecheck: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/invoice?status=0',
                        table: 'invoice'
                    }
                });
                // 费用
                var table2 = $("#table25");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar25',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field : 'invoice.create_staff.name', title : __('提交人'), operate: false},

                            {field: 'invoice.customer', title: __('客户名称'), operate:false, formatter : function (value, row, index) {
                                    if(row.customer){
                                        return "<a href='javascript:void(0);' data-id='" + row.customer.id + "' class='show-customer'>" + row.customer.name + "</a>";
                                    }else{
                                        return '';
                                    }
                                }},
                            {field: 'invoice.contract', title: __('合同编号'), operate:false, formatter : function (value, row, index) {
                                    if(row.contract){
                                        return "<a href='javascript:void(0);' data-id='" + row.contract.id + "' class='show-contract'>" + row.contract.name + "</a>";
                                    }else{
                                        return '';
                                    }
                                }},
                            {field: 'invoice.number', title: __('发票编号'), operate:false, formatter : function (value, row, index) {
                                    if(!row.invoice){
                                        return '';
                                    }
                                    return "<a href='javascript:void(0);' class='btn-dialog invoice_number' data-area=[\"95%\",\"95%\"] data-shade=\"0.3\"\n" +
                                        "data-url=\"qingdongwms/finance/invoice/detail?ids=" + row.invoice.id+
                                        "\" data-title=\"发票详情\" ' >" + value + "</a>";
                                }},
                            {field: 'invoice.time', title: __('开票日期'), operate:false},
                            {field: 'invoice.money', title: __('消费金额'),operate:false},
                            {field: 'invoice.remark', title: __('备注'),operate:false},

                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'operate', title: __('Operate'), table: table2, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        area:'',
                                        refresh:true,
                                        icon: 'fa fa-check',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=invoice&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        icon: 'fa fa-close',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=invoice&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            console.log(data, ret);
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                ]
                            }

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });


                // 为表格2绑定事件
                Table.api.bindevent(table2);

            },
            invoicesuccess: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/invoice?status=1',
                        table: 'invoice'
                    }
                });
                // 费用
                var table2 = $("#table26");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar26',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field : 'invoice.create_staff.name', title : __('提交人'), operate: false},
                            {field: 'invoice.number', title: __('发票编号'), operate:false, formatter : function (value, row, index) {
                                    if(!row.invoice){
                                        return '';
                                    }
                                    return "<a href='javascript:void(0);' class='btn-dialog invoice_number' data-area=[\"95%\",\"95%\"] data-shade=\"0.3\"\n" +
                                        "data-url=\"qingdongwms/finance/invoice/detail?ids=" + row.invoice.id+
                                        "\" data-title=\"发票详情\" ' >" + value + "</a>";
                                }},
                            {field: 'invoice.time', title: __('开票日期'), operate:false},

                            {field: 'invoice.customer', title: __('关联客户'), operate:false, formatter : function (value, row, index) {
                                    if(row.customer){
                                        return "<a href='javascript:void(0);' data-id='" + row.customer.id + "' class='show-customer'>" + row.customer.name + "</a>";
                                    }else{
                                        return '';
                                    }
                                }},

                            {field: 'invoice.money', title: __('消费金额'),operate:false},
                            {field: 'invoice.remark', title: __('备注'),operate:false},

                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },
            //发货
            delivery: function () {
                Controller.table['deliverycheck'].call(this);
            },
            deliverycheck: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/delivery?status=0',
                        table: 'deliverys'
                    }
                });
                // 费用
                var table2 = $("#table27");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar27',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {
                                field : 'delivery.num', title : '发货单编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.delivery){
                                        return "<a href='javascript:void(0);' class='btn-dialog'" +
                                            "data-url='qingdongwms/customer/delivery/detail/ids/"+row.delivery.id+"' data-area=[\"95%\",\"95%\"] data-title='发货单详情' >" + value + "</a>";
                                    }else{
                                        return '';
                                    }

                                },operate:'like'
                            },
                            {field : 'delivery.customer', title : '客户名称', formatter : function (value, row, index) {
                                    if(row.delivery){
                                        return "<a href='javascript:void(0);' class='btn-dialog'" +
                                            "data-url='qingdongwms/customer/customer/detail/ids/"+row.delivery.customer_id+"' data-area=[\"95%\",\"95%\"] data-title='客户详情'>" + row.delivery.customer.name + "</a>";
                                    }
                                    return '';
                                },operate:false},
                            {field : 'delivery.order_date', title : '送货日期',operate: 'RANGE', addclass: 'datetimerange'},
                            {field : 'delivery.warehouse.name', title : '发货仓库',operate:false},
                            {field : 'delivery.money', title : '发货单金额',operate:false},
                            {field : 'delivery.check_status', title : '发货单状态',formatter:Table.api.formatter.status, searchList: {0:'待审核', 1: '审核中',2:'审核通过',3:"审核未通过",4:"已撤销"}},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field : 'delivery.staff.name', title : __('提交人'), operate: false},
                            {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                            {field: 'operate', title: __('Operate'), table: table2, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        area:'',
                                        refresh:true,
                                        icon: 'fa fa-check',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=delivery&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        icon: 'fa fa-close',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=delivery&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                ]
                            }

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });


                // 为表格2绑定事件
                Table.api.bindevent(table2);

            },
            deliverysuccess: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/delivery?status=1',
                        table: 'delivery'
                    }
                });
                // 费用
                var table2 = $("#table28");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar28',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {
                                field : 'delivery.num', title : '发货单编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.delivery){
                                        return "<a href='javascript:void(0);' class='btn-dialog'" +
                                            "data-url='qingdongwms/customer/delivery/detail/ids/"+row.delivery.id+"' data-area=[\"95%\",\"95%\"] data-title='发货单详情' >" + value + "</a>";
                                    }else{
                                        return '';
                                    }

                                },operate:'like'
                            },
                            {field : 'delivery.customer', title : '客户名称', formatter : function (value, row, index) {
                                    if(row.delivery){
                                        return "<a href='javascript:void(0);' class='btn-dialog' " +
                                            "data-url='qingdongwms/customer/customer/detail/ids/"+row.delivery.customer_id+"' data-area=[\"95%\",\"95%\"] data-title='客户详情'>" + row.delivery.customer.name + "</a>";
                                    }
                                    return '';
                                },operate:false},
                            {field : 'delivery.order_date', title : '送货日期',operate: 'RANGE', addclass: 'datetimerange'},
                            {field : 'delivery.warehouse.name', title : '发货仓库',operate:false},
                            {field : 'delivery.money', title : '发货单金额',operate:false},
                            {field : 'delivery.check_status', title : '发货单状态',formatter:Table.api.formatter.status, searchList: {0:'待审核', 1: '审核中',2:'审核通过',3:"审核未通过",4:"已撤销"}},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field : 'delivery.staff.name', title : __('提交人'), operate: false},
                            {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },
            //入库
            instock: function () {
                Controller.table['instockcheck'].call(this);
            },
            instockcheck: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/instock?status=0',
                        table: 'instock'
                    }
                });
                // 费用
                var table2 = $("#table29");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar29',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {
                                field : 'instock.num', title : '入库单编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(value =='' || !row.instock){
                                        value = '无';
                                    }
                                    return "<a href='javascript:void(0);'  class='btn-dialog' " +
                                        "data-url='qingdongwms/stock/instock/detail/ids/"+row.instock.id+"' data-area=[\"95%\",\"95%\"] data-title='入库单详情'>" + value + "</a>";
                                },operate:'like'
                            },
                            {field : 'instock.money', title : '入库单金额',operate:false},

                            {field : 'instock.remarks', title : '备注',operate:false},
                            {field : 'instock.check_status', title : '入库单状态',formatter:Table.api.formatter.status, searchList: {0:'待审核', 1: '审核中',2:'审核通过',3:"审核未通过",4:"已撤销"}},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field : 'instock.staff.name', title : __('提交人'), operate: false},
                            {field: 'instock.createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                            {field: 'operate', title: __('Operate'), table: table2, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        area:'',
                                        refresh:true,
                                        icon: 'fa fa-check',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=instock&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        icon: 'fa fa-close',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=instock&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                ]
                            }

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });


                // 为表格2绑定事件
                Table.api.bindevent(table2);

            },
            instocksuccess: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/instock?status=1',
                        table: 'instock'
                    }
                });
                // 费用
                var table2 = $("#table30");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar30',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {
                                field : 'instock.num', title : '入库单编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(value =='' || !row.instock){
                                        value = '无';
                                    }
                                    return "<a href='javascript:void(0);'  class='btn-dialog' " +
                                        "data-url='qingdongwms/stock/instock/detail/ids/"+row.instock.id+"' data-area=[\"95%\",\"95%\"] data-title='入库单详情'>" + value + "</a>";
                                },operate:'like'
                            },

                            {field : 'instock.money', title : '入库单金额',operate:false},

                            {field : 'instock.remarks', title : '备注',operate:false},
                            {field : 'instock.check_status', title : '入库单状态',formatter:Table.api.formatter.status, searchList: {0:'待审核', 1: '审核中',2:'审核通过',3:"审核未通过",4:"已撤销"}},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field : 'instock.staff.name', title : __('提交人'), operate: false},
                            {field: 'instock.createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },
            //出库
            outstock: function () {
                Controller.table['outstockcheck'].call(this);
            },
            outstockcheck: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/outstock?status=0',
                        table: 'outstock'
                    }
                });
                // 费用
                var table2 = $("#table31");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar31',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {
                                field : 'outstock.num', title : '出库单编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(value =='' || !row.outstock){
                                        value = '无';
                                    }
                                    return "<a href='javascript:void(0);'  class='btn-dialog' " +
                                        "data-url='qingdongwms/stock/outstock/detail/ids/"+row.outstock.id+"' data-area=[\"95%\",\"95%\"] data-title='出库单详情'>" + value + "</a>";
                                },operate:'like'
                            },

                            {field : 'outstock.money', title : '出库单金额',operate:false},

                            {field : 'outstock.remarks', title : '备注',operate:false},
                            {field : 'outstock.check_status', title : '出库单状态',formatter:Table.api.formatter.status, searchList: {0:'待审核', 1: '审核中',2:'审核通过',3:"审核未通过",4:"已撤销"}},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field : 'outstock.staff.name', title : __('提交人'), operate: false},
                            {field: 'outstock.createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                            {field: 'operate', title: __('Operate'), table: table2, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        area:'',
                                        refresh:true,
                                        icon: 'fa fa-check',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=outstock&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        icon: 'fa fa-close',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=outstock&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                        },
                                    },
                                ]
                            }

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });


                // 为表格2绑定事件
                Table.api.bindevent(table2);

            },
            outstocksuccess: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/outstock?status=1',
                        table: 'outstock'
                    }
                });
                // 费用
                var table2 = $("#table32");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar32',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {
                                field : 'outstock.num', title : '出库单编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(value =='' || !row.outstock){
                                        value = '无';
                                    }
                                    return "<a href='javascript:void(0);'  class='btn-dialog' " +
                                        "data-url='qingdongwms/stock/outstock/detail/ids/"+row.outstock.id+"' data-area=[\"95%\",\"95%\"] data-title='出库单详情'>" + value + "</a>";
                                },operate:'like'
                            },
                            {field : 'outstock.money', title : '出库单金额',operate:false},

                            {field : 'outstock.remarks', title : '备注',operate:false},
                            {field : 'outstock.check_status', title : '出库单状态',formatter:Table.api.formatter.status, searchList: {0:'待审核', 1: '审核中',2:'审核通过',3:"审核未通过",4:"已撤销"}},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field : 'outstock.staff.name', title : __('提交人'), operate: false},
                            {field: 'outstock.createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },
        },

        api    : {
            bindevent : function () {
                Form.api.bindevent($("form[role=form]"), function(data, ret){

                    //这里是表单提交处理成功后的回调函数，接收来自php的返回数据
                    Fast.api.close(data);//这里是重点
                });
            }
        }
    };
    return Controller;
});